www.gusucode.com > VC++ 分形图像编辑器源码源码程序 > VC++ 分形图像编辑器源码源码程序\code\FractalDoc.cpp

    //贵州省安顺市第二高级中学 高二一班 蒋伟	
//2002.7.1
//请勿修改版权信息 谢谢
//Neil
// Download by http://www.NewXing.com
// FractalDoc.cpp : implementation of the CFractalDoc class
//

#include "stdafx.h"
#include "Fractal.h"

#include "FractalDoc.h"
#include "time.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFractalDoc

IMPLEMENT_DYNCREATE(CFractalDoc, CDocument)

BEGIN_MESSAGE_MAP(CFractalDoc, CDocument)
	//{{AFX_MSG_MAP(CFractalDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFractalDoc construction/destruction

CFractalDoc::CFractalDoc(){}
CFractalDoc::~CFractalDoc(){}

BOOL CFractalDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	time_t now;
	if(time(&now)&1){
		m_bDrawPixel=false;
		m_branch_num=40;	
		m_last_branch_length=10;
		m_branch_length=300;
		m_right_branch_angle=20;
		m_left_branch_angle=80;
		m_cut_rate=0.618;
		m_color=RGB(128,77,3);
		m_linewidth=1;
	}
	else{
		m_bDrawPixel=true;
		m_branch_num=3;	
		m_last_branch_length=3;
		m_branch_length=100;
		m_right_branch_angle=9;
		m_left_branch_angle=9;
		m_cut_rate=0.3;
		m_color=RGB(230,60,20);
		m_linewidth=1;
	}

	::SendMessage(::GetActiveWindow(),WM_COMMAND,ID_VIEW_REFRESH,0);
	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CFractalDoc serialization

void CFractalDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		ar<<m_bDrawPixel<<m_branch_num;
		ar<<m_last_branch_length<<m_branch_length;
		ar<<m_right_branch_angle<<m_left_branch_angle;
		ar<<m_cut_rate<<m_color<<m_linewidth;
	}
	else
	{
		ar>>m_bDrawPixel>>m_branch_num;
		ar>>m_last_branch_length>>m_branch_length;
		ar>>m_right_branch_angle>>m_left_branch_angle;
		ar>>m_cut_rate>>m_color>>m_linewidth;

		::SendMessage(::GetActiveWindow(),WM_COMMAND,ID_VIEW_REFRESH,0);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CFractalDoc diagnostics

#ifdef _DEBUG
void CFractalDoc::AssertValid() const{CDocument::AssertValid();}
void CFractalDoc::Dump(CDumpContext& dc) const{CDocument::Dump(dc);}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFractalDoc commands